<?php defined('ALLOWED') OR die('No direct access allowed.');

#define constants
define( 'PATH_APP', 'app' . FILE_SEPARATOR);
define( 'PATH_SMILODON', 'smilodon' . FILE_SEPARATOR);
define( 'PATH_PLUGINS', 'plugins' . FILE_SEPARATOR);

class kernel
{
    public static function load()
    {
        return new kernel;
    }
    
    public function exception( $e)
    {
        if( is_array( $e))
        {
            for( $i = 0, $cnt = count( $e); $i < $cnt; $i++)
            {
                if( file_exists( 'smilodon' . FILE_SEPARATOR . 'vendors' . FILE_SEPARATOR . 'exception' . FILE_SEPARATOR . $e[$i] . '.php'))
                {
                    include 'smilodon' . FILE_SEPARATOR . 'vendors' . FILE_SEPARATOR . 'exception' . FILE_SEPARATOR . $e[$i] . '.php';
                }
            }
        }
        
        else
        {
            if( file_exists( 'smilodon' . FILE_SEPARATOR . 'vendors' . FILE_SEPARATOR . 'exception' . FILE_SEPARATOR . $e . '.php'))
            {
                include 'smilodon' . FILE_SEPARATOR . 'vendors' . FILE_SEPARATOR . 'exception' . FILE_SEPARATOR . $e . '.php';
            }
        }
        
        return $this;
    }
    
    public function loader()
    {
        
        #get required elements
        include PATH_SMILODON . 'system' . FILE_SEPARATOR . 'loader.php';

        new Loader();
        Loader::auto();
        
        #return obiect
        return $this;
    }
}

//run it
kernel::load()
-> exception( 'MainException')
-> loader();

try {
    throw new MainException( 'ss');
}

catch( MainException $e)
{
    echo $e;
}
